phy_rotation


Description

This variable can be used to get (or to set) the angle of the instances fixture in degrees, similar to setting or getting the image_angle. However note that in the physics world rotations are calculated in the opposite way to the normal GameMaker Studio 2 game world, meaning that vector functions like point_direction should have their return values modified (simply making positive to negative should resolve this).


Syntax:

phy_rotation;


Returns:

Real (single precision floating point value, or undefined if the instance is not physics enabled)


Example:

if phy_speed_x > 0 || phy_speed_y > 0
    {
    phy_rotation += sqrt(sqr(phy_speed_x) + sqr(phy_speed_y)) /10;
    }

The above code checks the linear speed and if either vector is not 0, it then calculates the actual speed and uses that to set the rotation.